wincc vbscript for access hmi screen items and tags

Published on Dec23, 2024 | Category: wincc tia
Share this article:

vbscript is a visual basic script used in wincc flexible for hmi programming and configuration. vbscript access hmi screen items to write and read screen items value. vb script is very help full to design HMI screen. vbscript also read and write tag value by using smart tags keyword. in industrial control system vbscript help to make HMI more user friendly. vb script have many useful features like read and write tag value, read and write screen items value and screen items propertis.in this article we understand how to read and write tag value and read and write screen items property and value.

add screen item in screen using wincc tia

open wincc tia and than create project after creating project open your screen and then add items like button, text field, input output field, slider etc. each screen items have it's unique name. this unique name is used for accessing screen items in vb script. in this article we access screen items in vb script.

img/wincc tags and items/add screen item in screen using wincc tia.webp

add tag in wincc

open tag table and add tag with proper data type in this article we have input1, input2 and input3 and each tag have integer (INT) data type.

img/wincc tags and items/add tag in wincc.webp

how to read and write value of tags using vbscript in siemens wincc tia portal

tag is very important in industrial control. tag is name of variable to identify of application. each tag associated with a proper data type. Siemens HMI tags are accessible in vbscript. you can use "Smarttag" keyword to access HMI or plc tag. or press CTRL+J to access tag table in vbscript. each tag store value like temperature, area, depth etc. following are the example of wicc vbscript to access tag.

img/wincc tags and items/how to read and write value of tags using vbscript in siemens wincc tia portal.webp

This example demonstrates how VBScript is used to assign values to tags using the SmartTags. input1, input2 and input3 are tags which are we inserted in hmi tag table, in this script we simple store values in tags. this vbscript is associated with button press events property. this subroutine vbscript executed when button pressed. following are code explanation

vbscript to access screen items in wincc tia portal

each screen items are associated with a screen name. screen items like text field, button, input output field etc have it's unique name. in vbscript screen name and screen items name are very important to access screen items. in vb script following items property changed.

following are the procedure to access screen items in vb script Dim items_var Set items_var = HmiRuntime.Screens("Screen_name").ScreenItems("screen_item_name")

img/wincc tags and items/vbscript to access screen items in wincc tia portal.webp

above is the vbscript example of accessing screen items property in wincc. in this script we access text property of a text fild. when button is pressed than text field changed to "button is pressed", text field color changed to red and width of text filed is changed to 4. following are code explanation in simple form